package com.fr.lintcode;

import org.junit.Test;

/**
 * @author 付荣
 * @version 创建时间：2019年1月31日 上午11:07:58
 */
public class Q8 {
	/**
     * @param str: An array of char
     * @param offset: An integer
     * @return: nothing
     */
    public void rotateString(char[] str, int offset) {
        int length = str.length;
        char[] tmp = new char[length];
        for(int i = 0; i < length; i++){
        	int k = (i + offset) % length;
        	tmp [k]= str[i];
        }
        for(int i = 0; i < length; i++){
        	str [i]= tmp[i];
        }
    }
    
    @Test
    public void testA() {
    	char[] str = "abcdefg".toCharArray();
		int offset = 3;
		rotateString(str, offset);
		System.out.println(str);
	}
}
